home *** CD-ROM | disk | FTP | other *** search
/ Aminet 2 / Aminet AMIGA CDROM (1994)(Walnut Creek)[Feb 1994][W.O. 44790-1].iso / Aminet / dev / lang / BCPL4Amiga.lha / tripos / myendcli.c < prev    next >
C/C++ Source or Header  |  1988-12-06  |  2KB  |  69 lines

  1. /* Myendcli.c - a C language replacement for ENDCLI
  2. Compile and link with Manx 3.4:
  3.   cc myendcli
  4.   ln myendcli.o bcpllib.o -lc
  5. By Bill Kinnersley - Dec 18, 1987
  6. Mail:   Physics Dept.
  7.         Montana State University
  8.         Bozeman, MT 59717
  9. BITNET: iphwk@mtsunix1
  10. INTERNET: iphwk%mtsunix1.bitnet@cunyvm.cuny.edu
  11. UUCP: ...psuvax1!mtsunix1.bitnet!iphwk
  12. */
  13. #include <stdio.h>
  14. #include <libraries/dosextens.h>
  15. #include <functions.h>
  16. #define DOSTRUE -1
  17.  
  18. struct Process *task;
  19. struct CommandLineInterface *cli;
  20. struct FileHandle *mystdin;
  21. struct DosLibrary *doslib;
  22. struct RootNode *root;
  23. struct DosInfo *dosinfo;
  24. struct foo {
  25.         BPTR    next;
  26.         long    count;
  27.         BPTR    seg;
  28.         char    length;
  29.         char    name[1];
  30. };
  31. struct foo *list;
  32.  
  33. main() {
  34.         short i;
  35.         if (!(doslib = (struct DosLibrary *)OpenLibrary("dos.library",0L)))
  36.                 error("Can't open library\n");
  37.         /*printf("doslib=%lx\n",doslib);*/
  38.         root = (struct RootNode *)doslib->dl_Root;
  39.         /*printf("root=%lx\n",root);*/
  40.         dosinfo = (struct DosInfo *)BADDR(root->rn_Info);
  41.         /*printf("dosinfo=%lx\n",dosinfo);*/
  42.         list = (struct foo *)BADDR(dosinfo->di_NetHand);
  43.         task = (struct Process *)FindTask(0L);
  44.         cli = (struct CommandLineInterface *)BADDR(task->pr_CLI);
  45.         mystdin = (struct FileHandle *)BADDR(cli->cli_StandardInput);
  46.         mystdin->fh_End = 0;
  47.         cli->cli_CurrentInput = cli->cli_StandardInput;
  48.         cli->cli_Background = DOSTRUE;
  49.         if (cli->cli_Interactive)
  50.                 printf("Task %ld ending\n", task->pr_TaskNum);
  51.         Forbid();
  52.         while (list) {
  53. /*printf("list=%lx\n",list);printf("next=%lx\n",BADDR(list->next));
  54. printf("count=%ld\n",list->count);printf("seg=%lx\n",BADDR(list->seg));
  55. puts(list->name);*/
  56.                 if (strcmp("CLI",list->name)==0) break;
  57.                 list = (struct foo *)BADDR(list->next);
  58.         }
  59.         if (list) {
  60. /*printf("list=%lx\n",list);printf("next=%lx\n",BADDR(list->next));
  61. printf("count=%ld\n",list->count);printf("seg=%lx\n",BADDR(list->seg));
  62. puts(list->name);*/
  63.                 if (list->count>0) list->count--;
  64.         }
  65.         Permit();
  66. }
  67.  
  68. error(s) char *s; {puts(s); exit(0);}
  69.